import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';

const bleStatusMap = <BleStatus, Map<String, dynamic>>{
  BleStatus.locationServicesDisabled: <String, String>{
    'name': '位置服务已禁用', // 仅限Android
  },
  BleStatus.poweredOff: <String, String>{
    'name': '蓝牙已关闭',
  },
  BleStatus.ready: <String, String>{
    'name': '蓝牙运行中',
  },
  BleStatus.unauthorized: <String, String>{
    'name': '当前应用未授予蓝牙权限',
  },
  BleStatus.unknown: <String, String>{
    'name': '蓝牙状态尚未确定',
  },
  BleStatus.unsupported: <String, String>{
    'name': '您的设备不支持低功耗蓝牙',
  },
};
const deviceStateMap = <DeviceConnectionState, Map<String, dynamic>>{
  DeviceConnectionState.connected: <String, String>{
    'name': '已连接',
  },
  DeviceConnectionState.connecting: <String, String>{
    'name': '连接中',
  },
  DeviceConnectionState.disconnected: <String, String>{
    'name': '已断开',
  },
  DeviceConnectionState.disconnecting: <String, String>{
    'name': '断开中',
  },
};

class Dict {
  static String? getByNameKey(Map<dynamic, dynamic> source, dynamic key) {
    if (source.containsKey(key)) {
      return source[key]!['name'] as String;
    }
  }
}

abstract class Cache<T, T1> {
  T1? getByNameKey(T key);
  void setByNameKey(T key, T1? Value);
}
